/**
 * Project Name:common-core
 * File Name:ThreadCacheContext.java
 * Package Name:com.wu.common.core.context
 * Date:2016年3月12日下午12:44:35
 * Copyright (c) 2016, worldunion All Rights Reserved.
 *
 */

package com.dz.common.context;

import java.util.HashMap;
import java.util.Map;

/**
 * ClassName: ThreadCacheContext <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2016年3月12日 下午12:44:35 <br/>
 *
 * @author yexx
 * @version
 * 
 */
public class ThreadCacheContext extends AbstractContext {

	private static final String CACHE_KEY = "$localMapCache$";

	public static Object getFromLoalCache(String key) {
		@SuppressWarnings("unchecked")
		Map<String, Object> localCache = (Map<String, Object>) get(CACHE_KEY);
		if (localCache != null) {
			return localCache.get(key);
		} else {
			return null;
		}
	}
	
	@SuppressWarnings("unchecked")
	public static void putInCache(String key,Object value){
		Map<String, Object> localCache = (Map<String, Object>) get(CACHE_KEY);
		if(localCache==null){
			localCache=new HashMap<String, Object>();
			put(CACHE_KEY, localCache);
		}
		localCache.put(key, value);
	}
}
